#include "signup.srpc.h"
#include "workflow/WFFacilities.h"
#include <iostream>
using std::cout;
using namespace srpc;

static WFFacilities::WaitGroup wait_group(1);

void sig_handler(int signo)
{
	wait_group.done();
}

static void signup_done(RespSignup *response, srpc::RPCContext *context){
	cout << "code = " << response->code()
	     << " information = " << response->information()
		 << "\n";
}

int main()
{
	GOOGLE_PROTOBUF_VERIFY_VERSION;
	const char *ip = "127.0.0.1";
	unsigned short port = 1412;//服务端端口号
	// client是client_stub 是服务端在客户端的代理
	UserService::SRPCClient client(ip, port);

	ReqSignup request;
	request.set_username("admin");
	request.set_password("123");
	// // Signup是异步的
	// client.Signup(&request, signup_done);

	// 创建一个rpc类型的任务
	auto rpctask = client.create_Signup_task(signup_done);
	// 将请求序列化，设置为任务的属性
	rpctask->serialize_input(&request);
	rpctask->start();
	
	wait_group.wait();
	google::protobuf::ShutdownProtobufLibrary();
	return 0;
}
